package com.mezz.bones.user.application.repository.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mezz.bones.framework.base.domain.enums.ResponseCode;
import com.mezz.bones.framework.base.exception.BaseException;
import com.mezz.bones.user.application.mapper.ISysRoleMapper;
import com.mezz.bones.user.application.repository.ISysRoleRepository;
import com.mezz.bones.user.client.domain.entity.SysRole;
import org.springframework.stereotype.Service;

@Service
public class SysRoleRepositoryImpl extends ServiceImpl<ISysRoleMapper, SysRole> implements ISysRoleRepository {

    @Override
    public SysRole getByIdWithException(String id) {

        SysRole sysRole = this.getById(id);
        if(sysRole == null) {
            throw new BaseException(ResponseCode.DATA_NOT_FOUND, "角色不存在");
        }

        return sysRole;
    }
}
